package cn.good.user.service;

import cn.good.mapper.UserMapper;
import cn.good.pojo.User;
import cn.good.service.UserService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Service(interfaceClass = UserService.class)
public class RPCUserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    /**
     * 根据用户名查询用户
     * @param userCode
     * @return
     */
    @Override
    public User getUserByUserCode(String userCode) throws Exception{
        return userMapper.selectUserByuserCode(userCode);
    }

    /**
     * 保存用户
     * @param user
     * @return
     * @throws Exception
     */
    @Override
    public Boolean saveUser(User user) throws Exception {
        return userMapper.insert(user)>0;
    }

    /**
     * 根据用户id查询用户
     * @param aLong
     * @return
     * @throws Exception
     */
    @Override
    public User getUserByKey(Long aLong) throws Exception {
        return userMapper.selectByPrimaryKey(aLong);
    }
}
